home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Compute! Gazette 1992 June
/
1992-06.d64
/
pad design
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
5KB
|
132 lines
0 clr
10 rem copyright 1992 compute publications intl ltd - all rights reserved
100 rem *** initialize ***
110 hd$=" pad design ":deffnpm(x)=10^(1-(x<1)+(x>1000))
120 cc$(1)=" ":cc$(2)="[159]results with new 'r' values[154]"
130 lo$(1)="insertion loss":lo$(2)="minimum-loss"
140 an$(1)="t or h ":an$(2)="[255] or o ":an$(3)="min-loss"
150 poke783,peek(783)and254:poke53281,0:poke53280,0
160 rem *** main menu ***
170 print"[147]";:fori=1to40:print" ";:next
180 print""tab(5)hd$
190 ro=3:co=5:gosub1150:print"select:":co=10:fori=1to3
200 ro=ro+2:gosub1150:printi" - "an$(i):next
210 input"choice:";p$:ifp$<"1"orp$>"3"then210
220 ph=1
230 input"enter input impedance";zi:ifzi=0 thengosub1260:goto230
240 input"enter output impedance";zo:ifzo=0thengosub1260:goto240
250 ifp$="3"andzo=zithenprint"min-loss is to match z's":goto1210
260 ifp$="3"then300
270 input"enter attenuation in db.";at
280 ifat=0then1250
290 n=exp(log(10)*at/10)
300 onval(p$)goto310,440,570
310 rem *** calc for t or h ***
320 r3=2*sqr(zi*zo*n)/(n-1)
330 r1=zi*(n+1)/(n-1)-r3:r1=int(fnpm(r1)*r1+.5)/fnpm(r1)
340 r2=zo*(n+1)/(n-1)-r3:r2=int(fnpm(r2)*r2+.5)/fnpm(r2)
350 r3=int(fnpm(r3)*r3+.5)/fnpm(r3)
360 ifsgn(r2)=-1then1230
370 ra=r1:rb=r2:rc=r3
380 goto690
390 za=(zo+r2)*r3/(zo+r2+r3)+r1:za=int(fnpm(za)*za+.5)/fnpm(za)
400 zb=(zi+r1)*r3/(zi+r1+r3)+r2:zb=int(fnpm(zb)*zb+.5)/fnpm(zb)
410 vl=1/((zo+r2)*r3/((zo+r2+r3)*za)*zo/(zo+r2))
420 at=int(100*(20*log(vl)/log(10)-10*log(za/zo)/log(10))+.5)/100
430 goto690
440 rem *** calc for ' or o ***
450 r3=(n-1)/2*sqr(zi*zo/n)
460 r1=1/(1/zi*(n+1)/(n-1)-(1/r3)):r1=int(fnpm(r1)*r1+.5)/fnpm(r1)
470 r2=1/(1/zo*(n+1)/(n-1)-(1/r3)):r2=int(fnpm(r2)*r2+.5)/fnpm(r2)
480 r3=int(fnpm(r3)*r3+.5)/fnpm(r3)
490 ifsgn(r1)=-1then1230
500 ra=r1:rb=r2:rc=r3
510 goto870
520 oz=zo*r2/(zo+r2):iz=zi*r1/(zi+r1)
530 za=(oz+r3)*r1/(oz+r1+r3):za=int(fnpm(za)*za+.5)/fnpm(za)
540 zb=(iz+r3)*r2/(iz+r2+r3):zb=int(fnpm(zb)*zb+.5)/fnpm(zb)
550 at=int(100*(20*log((oz+r3)/oz)/log(10)-10*log(za/zo)/log(10))+.5)/100
560 goto870
570 rem *** calc for min-loss ***
580 ifzo>zithenz=zi:zi=zo:zo=z
590 r3=zo/sqr(1-(zo/zi)):r3=int(fnpm(r3)*r3+.5)/fnpm(r3)
600 r1=zi*sqr(1-(zo/zi)):r1=int(fnpm(r1)*r1+.5)/fnpm(r1)
610 za=zi
620 ra=r1:rb=r2:rc=r3
630 goto660
640 za=zo*r3/(zo+r3)+r1:za=int(fnpm(za)*za+.5)/fnpm(za)
650 zb=(zi+r1)*r3/(zi+r1+r3):zb=int(fnpm(zb)*zb+.5)/fnpm(zb)
660 vl=za/(zo*r3/(zo+r3))
670 at=int(100*(20*log(vl)/log(10)-10*log(za/zo)/log(10))+.5)/100
680 goto1000
690 rem *** display t network ***
700 print"[147]"hd$" "an$(1)
710 printtab(5)cc$(ph)
720 printtab(49)"[195][195][195][195] [154][146][195][195][178][195][195] [154][146][195][195][195]"
730 printtab(10)" [194]"
740 printtab(10)" r1 [154][146] r2"
750 printtab(10)" [154][146] r3"
760 printtab(10)" [154][146]"
770 printtab(10)" [164][164][164][154] [194] [164][164][164][154]"
780 printtab(9)"[195][195][195][195][195][195][195][195][195][177][195][195][195][195][195][195][195][195]"
790 printtab(10)" [163]^[163][154] [163]^[163][154]"
800 print"^ note: if balanced h then r1 & r2"
810 print" are halved."
820 print"r1="r1tab(15)"r2="r2tab(30)"r3="r3
830 ro=5:co=3:gosub1150:ifph=1thenprint"zi"zitab(30)"zo"zo:goto850
840 print"zi[159]"zatab(30)"[154]zo"zo:ro=7:gosub1150:print" "zitab(30)" [159]"zb"[154]"
850 ro=11:co=10:gosub1150:printlo$(int(val(p$)/2+.5));at" db"
860 goto1160
870 rem *** display (NULL) network ***
880 print"[147]"hd$" "an$(2)
890 printtab(5)cc$(ph)
900 printtab(50)"[195][195][195][195][195][178][195][195] [146][154][195][195][178][195][195][195][195]"
910 printtab(10)" [194] [194]"
920 printtab(10)" [146][154] r3 [146][154]"
930 printtab(10)" [146][154] r1 [146][154] r2"
940 printtab(10)" [146][154] [146][154]"
950 printtab(10)" [194] [164][164][164][154] [194]"
960 printtab(10)"[195][195][195][195][195][177][195][195][195][195][195][195][195][177][195][195][195][195]"
970 printtab(10)" [163]^[163][154]"
980 print"^ note: if balanced o then r3 is halved"
990 goto820
1000 rem *** display min-loss ***
1010 print"[147]"hd$" "an$(3)
1020 printtab(5)cc$(ph)
1030 printtab(49)"[195][195][195][195] [154][146][195][195][178][195][195][195][195][195][195][195][195]"
1040 printtab(10)" [194]"
1050 printtab(10)" r1 [154][146]"
1060 printtab(10)" [154][146] r3"
1070 printtab(10)" [154][146]"
1080 printtab(10)" [164][164][164][154] [194]"
1090 printtab(9)"[195][195][195][195][195][195][195][195][195][177][195][195][195][195][195][195][195][195]"
1100 printtab(10)" [163]^[163][154]"
1110 print"^ note: if balanced then r1 is halved."
1120 print"r1="r1tab(30)"r3="r3
1130 goto830
1140 rem *** sub-rtes ***
1150 poke781,ro:poke782,co:sys65520:return
1160 ro=22:co=0:gosub1150:print"[159]1-enter new r values 2-menu 3-quit[154]"
1170 geta$:ifa$<>"1"anda$<>"2"anda$<>"3"then1170
1180 ifa$="2"then160
1190 ifa$="3"thenprint"[147]":poke53281,6:poke53280,14:end
1200 print"[147]":gosub1270:onval(p$)goto390,520,640
1210 print"[159]hit shift to redo[154]":wait653,1:goto160
1220 print"value entered is > or < than 20% of":printtab(10)r:return
1230 print"the insertion loss is < min.loss -"
1240 print" redo or choose min.loss":goto1210
1250 print" some insertion loss must exist ":goto1210
1260 print" some impedance must exist ":return
1270 rem *** get new r values ***
1280 ro=4:co=5:gosub1150:print"[159]return[146] only for original r value[154]"
1290 ph=2:r1$="":r2$="":r3$=""
1300 input"enter new r1 value";r1$:r1=val(r1$):ifr1$=""thenr1=ra:goto1320
1310 ifabs(val(r1$)-ra)>.2*rathenr=ra:r1$="":gosub1220:goto1300
1320 ifp$="3"then1350
1330 input"enter new r2 value";r2$:r2=val(r2$):ifr2$=""thenr2=rb:goto1350
1340 ifabs(val(r2$)-rb)>.2*rbthenr=rb:r2$="":gosub1220:goto1330
1350 input"enter new r3 value";r3$:r3=val(r3$):ifr3$=""thenr3=rc:goto1370
1360 ifabs(val(r3$)-rc)>.2*rcthenr=rc:r3$="":gosub1220:goto1350
1370 ifr1=raandr2=rbandr3=rcthenph=1
1380 return